#Boa:Dialog:FileEsclusiDialog

import wx

def create(parent):
    return FileEsclusiDialog(parent)

[wxID_FILEESCLUSIDIALOG, wxID_FILEESCLUSIDIALOGADDBUTTON, 
 wxID_FILEESCLUSIDIALOGBROWSBUTTON, wxID_FILEESCLUSIDIALOGESCIBUTTON, 
 wxID_FILEESCLUSIDIALOGITEMTEXT, wxID_FILEESCLUSIDIALOGLISTAESCLUSIVIEW, 
 wxID_FILEESCLUSIDIALOGREMOVEBUTTON, wxID_FILEESCLUSIDIALOGSALVABUTTON, 
 wxID_FILEESCLUSIDIALOGSTATICTEXT1, 
] = [wx.NewId() for _init_ctrls in range(9)]

class FileEsclusiDialog(wx.Dialog):
    def _init_ctrls(self, prnt):
        # generated method, don't edit
        wx.Dialog.__init__(self, id=wxID_FILEESCLUSIDIALOG,
              name='FileEsclusiDialog', parent=prnt, pos=wx.Point(421, 334),
              size=wx.Size(386, 321), style=wx.DEFAULT_DIALOG_STYLE,
              title='File esclusi')
        self.SetClientSize(wx.Size(378, 288))

        self.staticText1 = wx.StaticText(id=wxID_FILEESCLUSIDIALOGSTATICTEXT1,
              label='File / Estensione', name='staticText1', parent=self,
              pos=wx.Point(8, 8), size=wx.Size(78, 13), style=0)

        self.ItemText = wx.TextCtrl(id=wxID_FILEESCLUSIDIALOGITEMTEXT,
              name='ItemText', parent=self, pos=wx.Point(96, 8),
              size=wx.Size(224, 21), style=0, value='')

        self.BrowsButton = wx.Button(id=wxID_FILEESCLUSIDIALOGBROWSBUTTON,
              label='...', name='BrowsButton', parent=self, pos=wx.Point(328,
              8), size=wx.Size(32, 23), style=0)
        self.BrowsButton.Bind(wx.EVT_BUTTON, self.OnBrowsButtonButton,
              id=wxID_FILEESCLUSIDIALOGBROWSBUTTON)

        self.ListaEsclusiView = wx.ListCtrl(id=wxID_FILEESCLUSIDIALOGLISTAESCLUSIVIEW,
              name='ListaEsclusiView', parent=self, pos=wx.Point(8, 72),
              size=wx.Size(360, 168), style=wx.LC_LIST)
        self.ListaEsclusiView.Bind(wx.EVT_LIST_ITEM_ACTIVATED,
              self.OnListaEsclusiViewListItemActivated,
              id=wxID_FILEESCLUSIDIALOGLISTAESCLUSIVIEW)

        self.AddButton = wx.Button(id=wxID_FILEESCLUSIDIALOGADDBUTTON,
              label='Add', name='AddButton', parent=self, pos=wx.Point(72, 40),
              size=wx.Size(75, 23), style=0)
        self.AddButton.Bind(wx.EVT_BUTTON, self.OnAddButtonButton,
              id=wxID_FILEESCLUSIDIALOGADDBUTTON)

        self.RemoveButton = wx.Button(id=wxID_FILEESCLUSIDIALOGREMOVEBUTTON,
              label='Remove', name='RemoveButton', parent=self,
              pos=wx.Point(216, 40), size=wx.Size(75, 23), style=0)
        self.RemoveButton.Bind(wx.EVT_BUTTON, self.OnRemoveButtonButton,
              id=wxID_FILEESCLUSIDIALOGREMOVEBUTTON)

        self.SalvaButton = wx.Button(id=wxID_FILEESCLUSIDIALOGSALVABUTTON,
              label='Salva', name='SalvaButton', parent=self, pos=wx.Point(72,
              256), size=wx.Size(75, 23), style=0)
        self.SalvaButton.Bind(wx.EVT_BUTTON, self.OnSalvaButtonButton,
              id=wxID_FILEESCLUSIDIALOGSALVABUTTON)

        self.EsciButton = wx.Button(id=wxID_FILEESCLUSIDIALOGESCIBUTTON,
              label='Esci', name='EsciButton', parent=self, pos=wx.Point(224,
              256), size=wx.Size(75, 23), style=0)
        self.EsciButton.Bind(wx.EVT_BUTTON, self.OnEsciButtonButton,
              id=wxID_FILEESCLUSIDIALOGESCIBUTTON)

    def __init__(self, parent, FileEsclusi):
        self._init_ctrls(parent)
        self.FileEsclusi = FileEsclusi
        self.index = 0
        self.Selected = ''
        for file in self.FileEsclusi:
            self.ListaEsclusiView.InsertStringItem(self.index, file)
            self.index +=1

    def OnBrowsButtonButton(self, event):
        dlg = wx.DirDialog(self)
        try:
            if dlg.ShowModal() == wx.ID_OK:
                path = dlg.GetPath()
                self.SorgenteText.SetValue(path)
        finally:
            dlg.Destroy()

    def OnListaEsclusiViewListItemActivated(self, event):
        self.Selected = event.GetIndex()

    def OnAddButtonButton(self, event):
        file = self.ItemText.GetValue()
        self.ListaEsclusiView.InsertStringItem(self.index, file)

    def OnRemoveButtonButton(self, event):
        if self.Selected != '':
            self.ListaEsclusiView.DeleteItem(self.Selected)
        else:
            dlg = wx.MessageDialog(self, 'Devi selezionare almeno un oggetto!', 'Attenzione', wx.OK | wx.ICON_INFORMATION)
            try:
                result = dlg.ShowModal()
            finally:
                dlg.Destroy()
                
    def OnSalvaButtonButton(self, event):
        event.Skip()

    def OnEsciButtonButton(self, event):
        self.Close()

    def getValues(self):
        return self.FileEsclusi